package demo1.dao.sql;

import demo1.dao.Mapper.userMapper;
import demo1.pojo.*;
import demo1.utils.connention;

import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class userSql implements userMapper {
    @Override
    public ResultSet checkNickName(String nickName,String userPwd) throws Exception {//检查昵称和密码能不能对的上
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_nickname = ? and user_pwd = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,nickName);
        pstmt.setString(2,userPwd);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet checkPhone(String userPhone, String userPwd) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_phone = ? and user_pwd = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userPhone);
        pstmt.setString(2,userPwd);
        //执行sql
        return pstmt.executeQuery();
    }

    public ResultSet selectAll() throws Exception {//查询所有
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAllAddress() throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users_address";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAllAddressById(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users_address where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAllById(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAllChangeUser(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from change_user where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAllOrder(int orderID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from orderform where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,orderID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAddressById(int addressID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users_address where address_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,addressID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectGouwucarById(int goodsID, int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from gouwucar where goods_id = ? and user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,goodsID);
        pstmt.setInt(2,userID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectAllOrderForm() throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from orderform";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectSignIn(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from sign_in where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectChangeUser(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from change_user where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public ResultSet selectUserPrice(int priceID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users_price where price_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,priceID);
        //执行sql
        return pstmt.executeQuery();
    }

    @Override
    public users selectUserByNickName(String userNickName) throws Exception {//通过昵称登录
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_nickname = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userNickName);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        if(rs.next()){
            String userName = rs.getString("user_name");
            String userPwd = rs.getString("user_pwd");
            String userAddress = rs.getString("user_address");
            String userDo = rs.getString("user_do");
            String userPhone = rs.getString("user_phone");
            String userAccount = rs.getString("user_account");
            String shopName = rs.getString("shop_name");
            int userID = rs.getInt("user_id");
            int money = rs.getInt("money");
            int panduan = rs.getInt("panduan");
            users users = new users();
            users.setUserName(userName);
            users.setShopName(shopName);
            users.setUserPwd(userPwd);
            users.setUserAddress(userAddress);
            users.setUserDo(userDo);
            users.setUserNickName(userNickName);
            users.setUserPhone(userPhone);
            users.setUserAccount(userAccount);
            users.setUserID(userID);
            users.setMoney(money);
            users.setPanduan(panduan);
            users.setCheckpass("");
            users.setPass("");
            return users;
        }
        return null;
    }

    @Override
    public users selectUserByPhone(String userPhone) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_phone = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userPhone);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        if(rs.next()){
            String userName = rs.getString("user_name");
            String userPwd = rs.getString("user_pwd");
            String userAddress = rs.getString("user_address");
            String userDo = rs.getString("user_do");
            String userNickName = rs.getString("user_nickname");
            String userAccount = rs.getString("user_account");
            String shopName = rs.getString("shop_name");
            int userID = rs.getInt("user_id");
            int money = rs.getInt("money");
            int panduan = rs.getInt("panduan");
            users users = new users();
            users.setUserName(userName);
            users.setShopName(shopName);
            users.setUserPwd(userPwd);
            users.setUserAddress(userAddress);
            users.setUserDo(userDo);
            users.setUserNickName(userNickName);
            users.setUserPhone(userPhone);
            users.setUserAccount(userAccount);
            users.setUserID(userID);
            users.setMoney(money);
            users.setPanduan(panduan);
            users.setCheckpass("");
            users.setPass("");
            return users;
        }
        return null;
    }

    @Override
    public users selectUserByAccount(String userAccount) throws Exception {//通过账号登录
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_account = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userAccount);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        if(rs.next()){
            String userName = rs.getString("user_name");
            String userPwd = rs.getString("user_pwd");
            String userAddress = rs.getString("user_address");
            String userDo = rs.getString("user_do");
            String userPhone = rs.getString("user_phone");
            String userNickName = rs.getString("user_nickname");
            String shopName = rs.getString("shop_name");
            int userID = rs.getInt("user_id");
            int money = rs.getInt("money");
            int panduan = rs.getInt("panduan");
            users users = new users();
            users.setUserName(userName);
            users.setShopName(shopName);
            users.setUserPwd(userPwd);
            users.setUserAddress(userAddress);
            users.setUserDo(userDo);
            users.setUserNickName(userNickName);
            users.setUserPhone(userPhone);
            users.setUserAccount(userAccount);
            users.setUserID(userID);
            users.setMoney(money);
            users.setPanduan(panduan);
            users.setCheckpass("");
            users.setPass("");
            return users;
        }
        return null;
    }

    @Override
    public List<AddressTableData> selectUserAddress(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users_address where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<AddressTableData> addressList = new ArrayList<>();
        AddressTableData address;
        while (rs.next()){
            if(rs.getInt("user_id") == userID){
                String userAddress = rs.getString("user_address");
                int addressID = rs.getInt("address_id");

                address = new AddressTableData();
                address.setUserID(userID);
                address.setAddressID(addressID);
                address.setUserAddress(userAddress);
                // 添加到列表中
                addressList.add(address);
            }
        }
        return addressList;
    }

    @Override
    public List<users> selectAllUsers() throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<users> usersList = new ArrayList<>();
        users users;
        while (rs.next()){
            if(rs.getInt("user_id") == 30){
                continue;//如果是管理自己就跳过
            }
            else {
                int userID = rs.getInt("user_id");
                int money = rs.getInt("money");
                int panduan = rs.getInt("panduan");
                String userName = rs.getString("user_name");//真实姓名
                String userDO = rs.getString("user_do");//真实姓名
                String userNickName = rs.getString("user_nickname");//昵称
                String userPhone = rs.getString("user_phone");
                String userAccount = rs.getString("user_account");
                String shopName = rs.getString("shop_name");

                users = new users();
                if(panduan == 0){
                    //为用户
                    users.setType("用户");
                }
                else if(panduan == 1) {
                    //为商户
                    users.setType("商户");
                }
                else if(panduan == 3){
                    //被封号
                    users.setType("被封号");
                }
                users.setUserID(userID);
                users.setMoney(money);
                users.setUserName(userName);
                users.setUserDo(userDO);
                users.setUserNickName(userNickName);
                users.setUserPhone(userPhone);
                users.setUserAccount(userAccount);
                users.setShopName(shopName);
                // 添加到列表中
                usersList.add(users);
            }
        }
        return usersList;
    }

    @Override
    public List<usersPrice> selectAllUsersPrice() throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users_price";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<usersPrice> usersPriceList = new ArrayList<>();
        usersPrice usersPrice;
        while (rs.next()) {
            int userID = rs.getInt("user_id");
            int price = rs.getInt("price");
            int priceStatue = rs.getInt("price_statue");
            int priceID = rs.getInt("price_id");

            usersPrice = new usersPrice();
            if (priceStatue == 0) {
                //未处理
                usersPrice.setStatue("未处理");
            } else if (priceStatue == 1) {
                //已处理
                usersPrice.setStatue("已处理");
            }
            usersPrice.setUserID(userID);
            usersPrice.setPrice(price);
            usersPrice.setPriceID(priceID);
            usersPrice.setPriceStatue(priceStatue);
            // 添加到列表中
            usersPriceList.add(usersPrice);
        }
        return usersPriceList;
    }

    @Override
    public List<changeUser> selectAllChangeUsers() throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from change_user";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<changeUser> changeUserList = new ArrayList<>();
        changeUser changeUser;
        while (rs.next()){
            if(rs.getInt("user_id") == 30){
                continue;//如果是管理自己就跳过
            }
            else {
                int userID = rs.getInt("user_id");
                int statue = rs.getInt("statue");
                changeUser = new changeUser();
                if(statue == 0){
                    //未处理
                    changeUser.setUserStatue("未处理");
                }
                else {
                    changeUser.setUserStatue("已处理");
                }
                changeUser.setUserID(userID);
                // 添加到列表中
                changeUserList.add(changeUser);
            }
        }
        return changeUserList;
    }

    @Override
    public List<gouwucar> selectGouwucar(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from gouwucar where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<gouwucar> gouwucarList = new ArrayList<>();
        gouwucar gouwucar;
        while (rs.next()){
            if(rs.getInt("user_id") == userID){
                String userAddress = rs.getString("user_address");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int goodsID = rs.getInt("goods_id");
                int goodsNum = rs.getInt("goods_num");

                gouwucar = new gouwucar();
                gouwucar.setUserAddress(userAddress);
                gouwucar.setGoodsName(goodsName);
                gouwucar.setGoodsMessage(goodsMessage);
                gouwucar.setPrice(price);
                gouwucar.setGoodsID(goodsID);
                gouwucar.setGoodsNum(goodsNum);
                gouwucar.setUserID(userID);
                // 添加到列表中
                gouwucarList.add(gouwucar);
            }
        }
        return gouwucarList;
    }

    @Override
    public List<orderForm> selectOrderForm(int userID) throws Exception {//显示待支付订单
        //比较一下时间看看有没有过
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from orderform where user_id = ? and statue = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        pstmt.setInt(2,0);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<orderForm> orderFormList = new ArrayList<>();
        orderForm orderForm;
        while (rs.next()){
            if(rs.getInt("user_id") == userID){
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                // 获取当前时间的Date
                Date currentDate = new Date();

                // 比较时间
                if (time.before(currentDate)) {
//                    //给定的时间已经过去了
                }
                else {
                    //给定的时间还未到来
                    orderForm = new orderForm();
                    orderForm.setDate(formattedDate);
                    orderForm.setTime(time);
                    orderForm.setUserAddress(userAddress);
                    orderForm.setGoodsName(goodsName);
                    orderForm.setGoodsMessage(goodsMessage);
                    orderForm.setPrice(price);
                    orderForm.setGoodsID(goodsID);
                    orderForm.setTotalPrice(totalPrice);
                    orderForm.setUserPhone(userPhone);
                    orderForm.setGoodsNum(goodsNum);
                    orderForm.setUserID(userID);
                    orderForm.setOrderID(orderID);
                    orderForm.setStatueOrderForm("待支付");
                    // 添加到列表中
                    orderFormList.add(orderForm);
                }
            }
        }
        return orderFormList;
    }

    @Override
    public List<orderForm> selectAllOrderForm(int userID) throws Exception {
        //比较一下时间看看有没有过
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from orderform where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //pstmt.setInt(2,0);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<orderForm> orderFormList = new ArrayList<>();
        orderForm orderForm;
        while (rs.next()){
            if(rs.getInt("statue") == 0){//状态为0，就是没有支付成功的
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                // 获取当前时间的Date
                Date currentDate = new Date();

                // 比较时间
                if (time.before(currentDate)) {
                    //如果时间过了
                    orderForm = new orderForm();
                    orderForm.setDate(formattedDate);
                    orderForm.setTime(time);
                    orderForm.setUserAddress(userAddress);
                    orderForm.setGoodsName(goodsName);
                    orderForm.setGoodsMessage(goodsMessage);
                    orderForm.setPrice(price);
                    orderForm.setGoodsID(goodsID);
                    orderForm.setTotalPrice(totalPrice);
                    orderForm.setUserPhone(userPhone);
                    orderForm.setGoodsNum(goodsNum);
                    orderForm.setUserID(userID);
                    orderForm.setOrderID(orderID);
                    orderForm.setStatueOrderForm("已过期");
                    // 添加到列表中
                    orderFormList.add(orderForm);
                }
                else {
                    //给定的时间还未到来
                    orderForm = new orderForm();
                    orderForm.setDate(formattedDate);
                    orderForm.setTime(time);
                    orderForm.setUserAddress(userAddress);
                    orderForm.setGoodsName(goodsName);
                    orderForm.setGoodsMessage(goodsMessage);
                    orderForm.setPrice(price);
                    orderForm.setGoodsID(goodsID);
                    orderForm.setTotalPrice(totalPrice);
                    orderForm.setUserPhone(userPhone);
                    orderForm.setGoodsNum(goodsNum);
                    orderForm.setUserID(userID);
                    orderForm.setOrderID(orderID);
                    orderForm.setStatueOrderForm("待支付");
                    // 添加到列表中
                    orderFormList.add(orderForm);
                }
            }
            else if(rs.getInt("statue") == 1){
                //成功支付
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                orderForm = new orderForm();
                orderForm.setDate(formattedDate);
                orderForm.setTime(time);
                orderForm.setUserAddress(userAddress);
                orderForm.setGoodsName(goodsName);
                orderForm.setGoodsMessage(goodsMessage);
                orderForm.setPrice(price);
                orderForm.setGoodsID(goodsID);
                orderForm.setTotalPrice(totalPrice);
                orderForm.setUserPhone(userPhone);
                orderForm.setGoodsNum(goodsNum);
                orderForm.setUserID(userID);
                orderForm.setOrderID(orderID);
                orderForm.setStatueOrderForm("支付成功");
                // 添加到列表中
                orderFormList.add(orderForm);
            }
            else if(rs.getInt("statue") == 2){
                //订单已取消
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                orderForm = new orderForm();
                orderForm.setDate(formattedDate);
                orderForm.setTime(time);
                orderForm.setUserAddress(userAddress);
                orderForm.setGoodsName(goodsName);
                orderForm.setGoodsMessage(goodsMessage);
                orderForm.setPrice(price);
                orderForm.setGoodsID(goodsID);
                orderForm.setTotalPrice(totalPrice);
                orderForm.setUserPhone(userPhone);
                orderForm.setGoodsNum(goodsNum);
                orderForm.setUserID(userID);
                orderForm.setOrderID(orderID);
                orderForm.setStatueOrderForm("订单已取消");
                // 添加到列表中
                orderFormList.add(orderForm);
            }
            else if(rs.getInt("statue") == 3){
                //订单正在退款
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                orderForm = new orderForm();
                orderForm.setDate(formattedDate);
                orderForm.setTime(time);
                orderForm.setUserAddress(userAddress);
                orderForm.setGoodsName(goodsName);
                orderForm.setGoodsMessage(goodsMessage);
                orderForm.setPrice(price);
                orderForm.setGoodsID(goodsID);
                orderForm.setTotalPrice(totalPrice);
                orderForm.setUserPhone(userPhone);
                orderForm.setGoodsNum(goodsNum);
                orderForm.setUserID(userID);
                orderForm.setOrderID(orderID);
                orderForm.setStatueOrderForm("订单正在退款");
                // 添加到列表中
                orderFormList.add(orderForm);
            }
            else if(rs.getInt("statue") == 4){
                //订单已退款成功
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                orderForm = new orderForm();
                orderForm.setDate(formattedDate);
                orderForm.setTime(time);
                orderForm.setUserAddress(userAddress);
                orderForm.setGoodsName(goodsName);
                orderForm.setGoodsMessage(goodsMessage);
                orderForm.setPrice(price);
                orderForm.setGoodsID(goodsID);
                orderForm.setTotalPrice(totalPrice);
                orderForm.setUserPhone(userPhone);
                orderForm.setGoodsNum(goodsNum);
                orderForm.setUserID(userID);
                orderForm.setOrderID(orderID);
                orderForm.setStatueOrderForm("订单已退款成功");
                // 添加到列表中
                orderFormList.add(orderForm);
            }
        }
        return orderFormList;
    }

    @Override
    public List<orderForm> selectSuccessOrderForm(int userID) throws Exception {
        //比较一下时间看看有没有过
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from orderform where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //pstmt.setInt(2,0);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<orderForm> orderFormList = new ArrayList<>();
        orderForm orderForm;
        while (rs.next()){
            if(rs.getInt("statue") == 1){
                //成功支付
                String userAddress = rs.getString("user_address");
                String userPhone = rs.getString("user_phone");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int totalPrice = rs.getInt("total_price");
                int goodsID = rs.getInt("goods_id");
                int orderID = rs.getInt("order_id");
                int goodsNum = rs.getInt("goods_num");
                Timestamp time = rs.getTimestamp("time");//商品上架时间
                String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

                orderForm = new orderForm();
                orderForm.setDate(formattedDate);
                orderForm.setTime(time);
                orderForm.setUserAddress(userAddress);
                orderForm.setGoodsName(goodsName);
                orderForm.setGoodsMessage(goodsMessage);
                orderForm.setPrice(price);
                orderForm.setGoodsID(goodsID);
                orderForm.setTotalPrice(totalPrice);
                orderForm.setUserPhone(userPhone);
                orderForm.setGoodsNum(goodsNum);
                orderForm.setUserID(userID);
                orderForm.setOrderID(orderID);
                orderForm.setGoodsComment("");
                orderForm.setGreatNum(1);
                orderForm.setStatueOrderForm("支付成功");
                // 添加到列表中
                orderFormList.add(orderForm);
            }
        }
        return orderFormList;
    }

    @Override
    public List<sign> selectAllSignNum() throws Exception {
        //比较一下时间看看有没有过
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from sign_in ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        List<sign> signList = new ArrayList<>();
        sign sign;
        int num = 0;;
        while (rs.next()) {
            num++;
            String userName = rs.getString("user_name");
            int userID = rs.getInt("user_id");
            int signID = rs.getInt("sign_id");
            Timestamp time = rs.getTimestamp("time");//商品上架时间
            String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

            sign = new sign();
            // 添加到列表中
            sign.setDate(formattedDate);
            sign.setSignID(signID);
            sign.setTime(time);
            sign.setUserID(userID);
            sign.setUserName(userName);
            sign.setNum(num);
            signList.add(sign);
        }
        return signList;
    }

    @Override
    public gouwucar selectGouwucarGoods(int goodsID, int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from gouwucar where user_id = ? and goods_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        pstmt.setInt(2,goodsID);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        gouwucar gouwucar = new gouwucar();;
        if (rs.next()){
            if(rs.getInt("user_id") == userID){
                String userAddress = rs.getString("user_address");
                String goodsName = rs.getString("goods_name");
                String goodsMessage = rs.getString("goods_message");
                int price = rs.getInt("price");
                int goodsNum = rs.getInt("goods_num");

                gouwucar.setUserAddress(userAddress);
                gouwucar.setGoodsName(goodsName);
                gouwucar.setGoodsMessage(goodsMessage);
                gouwucar.setPrice(price);
                gouwucar.setGoodsID(goodsID);
                gouwucar.setGoodsNum(goodsNum);
                gouwucar.setUserID(userID);
            }
        }
        return gouwucar;
    }

    @Override
    public orderForm selectOrderFormGoods(int orderID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from orderform where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,orderID);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        orderForm orderForm = new orderForm();
        if (rs.next()){
            String userAddress = rs.getString("user_address");
            String goodsName = rs.getString("goods_name");
            String goodsMessage = rs.getString("goods_message");
            String userPhone = rs.getString("user_phone");
            int price = rs.getInt("price");
            int goodsNum = rs.getInt("goods_num");
            int userID = rs.getInt("user_id");
            int totalPrice = rs.getInt("total_price");
            int goodsID = rs.getInt("goods_id");
            int statue = rs.getInt("statue");
            Timestamp time = rs.getTimestamp("time");

            orderForm.setUserAddress(userAddress);
            orderForm.setGoodsName(goodsName);
            orderForm.setGoodsMessage(goodsMessage);
            orderForm.setPrice(price);
            orderForm.setGoodsID(goodsID);
            orderForm.setGoodsNum(goodsNum);
            orderForm.setUserID(userID);
            orderForm.setUserPhone(userPhone);
            orderForm.setTotalPrice(totalPrice);
            orderForm.setTime(time);
            orderForm.setStatue(statue);
        }
        return orderForm;
    }

    @Override
    public address selectUserMorenAddress(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        //执行sql
        ResultSet rs = pstmt.executeQuery();
        address address = new address();
        if(rs.next()){
                String userAddress = rs.getString("user_address");

                address.setUserID(userID);
                address.setUserAddress(userAddress);
        }
        return address;
    }

    @Override
    public void insertUser(String userNickName, int panduan, String userPhone, String pass,String userAccount) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into users(user_nickname,user_pwd,user_phone,panduan,user_account,user_address,money,user_do,user_name,shop_name) values(?,?,?,?,?,?,?,?,?,?) ";
        //获取pstmt对象
        if(panduan == 0 ){
            //注册的是用户
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1,userNickName);
            pstmt.setString(2,pass);
            pstmt.setString(3,userPhone);
            pstmt.setInt(4,panduan);
            pstmt.setString(5,userAccount);
            pstmt.setString(6,"");
            pstmt.setInt(7,0);
            pstmt.setString(8,"");
            pstmt.setString(9,"");
            pstmt.setString(10,"");
            pstmt.executeUpdate();
        }
        else {
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1,userNickName);
            pstmt.setString(2,pass);
            pstmt.setString(3,userPhone);
            pstmt.setInt(4,panduan);
            pstmt.setString(5,userAccount);
            pstmt.setString(6,"");
            pstmt.setInt(7,0);
            pstmt.setString(8,"");
            pstmt.setString(9,"");
            pstmt.setString(10,userNickName+"的小店");
            pstmt.executeUpdate();
        }
    }

    @Override
    public void insertUserAddress(String userAddress, int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into users_address(user_address,user_id) values(?,?) ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userAddress);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void insertSignIn(String userName, int userID,Timestamp time) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into sign_in(user_name,user_id,time) values(?,?,?) ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userName);
        pstmt.setInt(2,userID);
        pstmt.setTimestamp(3,time);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void insertChangeUserStatue(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into change_user(user_id,statue) values(?,?) ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        pstmt.setInt(2,0);//表示未处理
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void insertGouwucarGoods(int userID, int price, String goodsMessage, String goodsName, int goodsNum, int goodsID, String userAddress) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into gouwucar(user_id,price,goods_message,goods_name,goods_num,goods_id,user_address) values(?,?,?,?,?,?,?) ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,userID);
        pstmt.setInt(2,price);
        pstmt.setString(3,goodsMessage);
        pstmt.setString(4,goodsName);
        pstmt.setInt(5,goodsNum);
        pstmt.setInt(6,goodsID);
        pstmt.setString(7,userAddress);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void insertOrderFormGoods(int userID, int price, int totalPrice, int goodsID, String goodsName, String goodsMessage, int goodsNum,String userAddress,String userPhone) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into orderform(user_id,time, price,total_price,goods_id,goods_name,goods_message,goods_num,statue,user_address,user_phone) values(?,?,?,?,?,?,?,?,?,?,?) ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        // 获取当前时间的Timestamp
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

        // 创建一个Calendar实例，并设置为当前Timestamp
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(timestamp);

        // 在当前时间的基础上增加5分钟
        calendar.add(Calendar.MINUTE, 5);

        // 获取更新后的Timestamp
        Timestamp updatedTimestamp = new Timestamp(calendar.getTimeInMillis());

        pstmt.setInt(1,userID);
        pstmt.setTimestamp(2,updatedTimestamp);
        pstmt.setInt(3,price);
        pstmt.setInt(4,totalPrice);
        pstmt.setInt(5,goodsID);
        pstmt.setString(6,goodsName);
        pstmt.setString(7,goodsMessage);
        pstmt.setInt(8,goodsNum);
        pstmt.setInt(9,0);
        pstmt.setString(10,userAddress);
        pstmt.setString(11,userPhone);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void insertOrderFormGoodsSuccess(int userID, int price, int totalPrice, int goodsID, String goodsName, String goodsMessage, int goodsNum, String userAddress, String userPhone) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into orderform(user_id, price,total_price,goods_id,goods_name,goods_message,goods_num,statue,user_address,user_phone) values(?,?,?,?,?,?,?,?,?,?) ";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        pstmt.setInt(1,userID);
        pstmt.setInt(2,price);
        pstmt.setInt(3,totalPrice);
        pstmt.setInt(4,goodsID);
        pstmt.setString(5,goodsName);
        pstmt.setString(6,goodsMessage);
        pstmt.setInt(7,goodsNum);
        pstmt.setInt(8,1);
        pstmt.setString(9,userAddress);
        pstmt.setString(10,userPhone);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateGouwucarGoodsNum(int goodsNum, int userID, int goodsID) throws Exception {//更新购物车里面的商品数
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update gouwucar set goods_num = ? where user_id = ? and goods_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,goodsNum);
        pstmt.setInt(2,userID);
        pstmt.setInt(3,goodsID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void modifyUserAddress(String userAddress, int addressID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users_address set user_address = ? where address_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userAddress);
        pstmt.setInt(2,addressID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUser(String userNickName, String userPhone, String userName,String userDo,int userID,String shopName) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users set user_nickname = ?, user_phone = ?,user_name = ?,user_do = ? ,shop_name = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userNickName);
        pstmt.setString(2,userPhone);
        pstmt.setString(3,userName);
        pstmt.setString(4,userDo);
        pstmt.setString(5,shopName);
        pstmt.setInt(6,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUserPass(String userPwd, int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users set user_pwd = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userPwd);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUserAddress(String userAddress, int userID) throws Exception {//更新默认地址
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users set user_address = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userAddress);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUserMoney(int money, int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users set money = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,money);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUserPanduan(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users set panduan = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,1);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUserPanduan2(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users set panduan = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,3);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateOrderFormStatue(int orderID) throws Exception {//成功支付
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update orderForm set statue = ? where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,1);
        pstmt.setInt(2,orderID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateOrderFormStatue3(int orderID) throws Exception {//正在退款
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update orderForm set statue = ? where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,3);
        pstmt.setInt(2,orderID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateOrderFormStatue4(int orderID) throws Exception {//退款成功
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update orderForm set statue = ? where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,4);
        pstmt.setInt(2,orderID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateOrderFormHandleStatue(int orderID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update orderForm set goods_handle = ? where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,1);
        pstmt.setInt(2,orderID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateChangeUserStatue(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update change_user set statue = ? where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,1);
        pstmt.setInt(2,userID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void updateUserPriceStatue(int priceID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update users_price set price_statue = ? where price_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,1);
        pstmt.setInt(2,priceID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void insertPriceStatue(int price, users users) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "insert into users_price (price_statue,price,user_id) values (?,?,?)";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,0);//钱还没有处理
        pstmt.setInt(2,price);
        pstmt.setInt(3,users.getUserID());
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void deleteOrderForm(int orderID) throws Exception {//取消订单
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update orderForm set statue = ? where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,2);
        pstmt.setInt(2,orderID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void deleteOrderForm2(int orderID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "delete from orderForm where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,orderID);
        //执行sql
        pstmt.executeUpdate();
    }

    @Override
    public void deleteAddress(int addressID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "delete from users_address where address_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setInt(1, addressID);
        //执行sql
        pstmt.executeUpdate();
        pstmt.close();
        conn.close();
    }

    @Override
    public void deleteGouwucarGoods(int goodsID, int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "delete from gouwucar where goods_id = ? and user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setInt(1, goodsID);
        pstmt.setInt(2, userID);
        //执行sql
        pstmt.executeUpdate();
        pstmt.close();
        conn.close();
    }

    @Override
    public void deleteGouwucarGoodsByGoodsID(int goodsID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "delete from gouwucar where goods_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setInt(1, goodsID);
        //执行sql
        pstmt.executeUpdate();
        pstmt.close();
        conn.close();
    }

    @Override
    public void deleteAllGouwucarGoods(int userID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "delete from gouwucar where user_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setInt(1, userID);
        //执行sql
        pstmt.executeUpdate();
        pstmt.close();
        conn.close();
    }

    @Override
    public void modifyOrderFormAddress(orderForm orderForm) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update orderform set user_address = ? where order_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setString(1, orderForm.getUserAddress());
        pstmt.setInt(2, orderForm.getOrderID());
        //执行sql
        pstmt.executeUpdate();
        pstmt.close();
        conn.close();
    }

    @Override
    public void modifyGouwucarGoods(float price, String goodsMessage, String goodsName, int goodsID) throws Exception {
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "update gouwucar set price = ?,goods_message = ?,goods_name = ? where goods_id = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setFloat(1, price);
        pstmt.setString(2, goodsMessage);
        pstmt.setString(3, goodsName);
        pstmt.setInt(4, goodsID);
        //执行sql
        pstmt.executeUpdate();
        pstmt.close();
        conn.close();
    }

    @Override
    public ResultSet checkUserAccount(String userAccount, String userPwd) throws Exception {//检查账号和密码能不能对的上
        connention connention = new connention();
        Connection conn = connention.conn();
        //Connection conn = conn();
        String sql = "select * from users where user_account = ? and user_pwd = ?";
        //获取pstmt对象
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1,userAccount);
        pstmt.setString(2,userPwd);
        //执行sql
        return pstmt.executeQuery();
    }

//    public Connection conn()throws Exception{
//        Class.forName("com.mysql.cj.jdbc.Driver");
//        //2.获取连接
//        String url = "jdbc:mysql://127.0.0.1:3306/project2";
//        String user = "root";
//        String password = "111214Cjj";
//
//        Connection conn = DriverManager.getConnection(url, user, password);
//        return conn;
//    }
}
